/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
/* Copyright (C) 2012 Zongyou Yao. All rights reserved.     */

#ifndef SEM_INCLUDED
#define SEM_INCLUDED

typedef struct sem_t {
    int count;
    void *queue;
} sem_t;

#define LOCK(mutex) do { sem_t *_yymutex = &(mutex); \
    sem_wait(_yymutex);
#define END_LOCK sem_signal(_yymutex); } while (0)

void sem_init(sem_t *s, int count);
sem_t * sem_new(int count);
void sem_wait(sem_t *s);
void sem_signal(sem_t *s);

#endif
